<?php
$host="db.seng.uvic.ca"; // Host name 
$username="se321g01"; // Mysql username 
$password="un8bi2YM"; // Mysql password 
$db_name="se321g01"; // Database name 
$tbl_name="user_info"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Personal 
$firstname=$_POST['ca_firstname'];
$lastname=$_POST['ca_lastname']; 
$email=$_POST['ca_email']; 
$password=$_POST['ca_password']; 

$uid = $_GET['uid'];

// Insert into user_info
mysql_query("INSERT INTO user_info (first_name,last_name,email,passwd,admin) VALUES
('$firstname','$lastname','$email','$password',1)");

// Get UID
$sql="SELECT * FROM $tbl_name WHERE email='$email' and passwd='$password'";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
$aid = $row['uid'];

// Insert into user_stats
mysql_query("INSERT INTO user_stats (time_left, points, uid) VALUES
('0', '0', '$aid')");

// Go to profile
header("location:./profile.php?uid=" . $uid . "&tab=2");

?>